//
//  DWRefreshView.swift
//  DWSwift
//
//  Created by GDL on 2025/6/20.
//

import Foundation
import SwiftUI
import Refresher

public struct DWRefreshTopView: View {
    @Binding var state: RefresherState
    @State private var angle: Double = 0.0
    @State private var isAnimating = false
    
    var foreverAnimation: Animation {
        Animation.linear(duration: 1.0)
            .repeatForever(autoreverses: false)
    }
    
    public var body: some View {
        VStack {
            switch state.mode {
            case .notRefreshing:
                Text("结果已经刷新").font(.system(size: 12))
//                    .onAppear {
//                        isAnimating = false
//                    }
            case .pulling:
                Text("释放刷新").font(.system(size: 12))
//                    .rotationEffect(.degrees(self.isAnimating ? 360.0 : 0.0))
//                        .onAppear {
//                            withAnimation(foreverAnimation) {
//                                isAnimating = true
//                            }
//                    }
            case .refreshing:
                Text("正在刷新")
//                    .rotationEffect(.degrees(360 * state.dragPosition))
            case .beginPull:
                Text("下拉刷新").font(.system(size: 12))
//                    .rotationEffect(.degrees(360 * state.dragPosition))
    
            }
        }
        .scaleEffect(2)
    }
}
